{layout name="public/layout" /}
{include file='yxnavbar'}


<div class="main">
    {include file='../../plugin/weike/template/web/gift/navbar'}

    {if !$has_demo_group}
    <div class="panel panel-info">
        <div class="panel-body">
            <form id="myform" action=""  class="form-horizontal" role="form">
                <div class="form-group" >
                    <label class="col-xs-1 col-sm-1 col-md-1 control-label">操作</label>
                    <div class="col-sm-1 col-lg-1 col-md-1 col-xs-2">
                        <a onclick="importDefaultItems(this)" data-themeid="{$themeid}" class="btn btn-primary">导入默认礼品数据</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
    {/if}



    <div class="tab-content">
        <div class="panel panel-default">
            <div class="panel-body table-responsive">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                        <tr>
                            <th style="width: 50px">序号</th>
                            <th style="width: 100px">分组名称</th>
                            <th style="width: 100px">状态</th>
                            <th style="width: 100px">管理</th>
                            <th style="width: 100px">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                    {loop $list $index $item}
                        <tr>
                            <td>{php echo $index+1;}</td>
                            <td>{$item['title']}</td>
                            <td>{php echo $item['status']==1 ?'可用':'已禁用';}</td>
                            <td>
                                <a href="{php echo createWebUrlPlugin('weike.gift.giftmain',array('themeid'=>$themeid,'group_id'=>$item['id']));}">
                                    <button class="btn btn-primary col-lg-6">打赏礼物管理</button>
                                </a>
                            </td>
                            <td>
                                <a class="btn btn-primary btn-sm" style="width: 35px"  data-type="edit" href="{php echo createWebUrlPlugin('weike.gift.addpage',array('themeid'=>$themeid,'group_id'=>$item['id']));}"
                                   title="编辑" data-toggle="tooltip" data-placement="top"><i class="fa fa-pencil-square-o"> </i></a>
                            </td>
                        </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>

{$pager}
<script type="text/javascript">
    $(document).ready(
        function (){
            console.log('js代码');
        }
    );

    function importDefaultItems(e)
    {
        var postUrl = "{php echo createWebUrlPlugin('weike.gift.insertDemoGift');}";
        let themeid = e.getAttribute("data-themeid");
        $.ajax({
            url:postUrl,
            dataType:'json',
            method:'post',
            data: {themeid:themeid},
            success:function (e) {
                let res = e.result;
                let status = e.status;
                let msg = res.msg;
                if (status!=1){
                    layer.msg(msg);
                }else{
                    layer.msg(msg);
                    location.reload();
                }

            },
            fail:function (err) {
                console.log(err)
            }
        });

    }
</script>
